home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1997 / HAM Radio 1997.iso / vcls / wfc007.000 / test / tcsess.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-08  |  1.2 KB  |  46 lines

  1. #include "test.h"
  2. #pragma hdrstop
  3.  
  4. void print_information( CNetworkSessionInformation& information )
  5. {
  6.    printf( "\"%s\" - \"%s\" - %d - %s - %s - %d - \"%s\" - \"%s\"\n",
  7.            (LPCTSTR) information.ClientName,
  8.            (LPCTSTR) information.UserName,
  9.                      information.NumberOfOpens,
  10.            (LPCTSTR) information.Time.Format( "%H:%M:%S" ),
  11.            (LPCTSTR) information.IdleTime.Format( "%H:%M:%S" ),
  12.                      information.UserFlags,
  13.            (LPCTSTR) information.ClientTypeName,
  14.            (LPCTSTR) information.Transport );
  15. }
  16.  
  17. void test_CNetSession( LPCTSTR machine_name )
  18. {
  19.    CNetworkSessions session;
  20.  
  21.    CNetworkSessionInformation information;
  22.  
  23.    session.Open( machine_name );
  24.  
  25.    if ( session.Enumerate( information ) )
  26.    {
  27.       print_information( information );
  28.  
  29.       while( session.GetNext( information ) )
  30.       {
  31.          print_information( information );
  32.       }
  33.    }
  34.    else
  35.    {
  36.       DWORD error_code = session.GetErrorCode();
  37.  
  38.       CString error_message;
  39.  
  40.       Convert_NERR_Code_to_String( error_code, error_message );
  41.  
  42.       printf( "CNetSession.ErrorCode == %d \"%s\"\n", error_code, (LPCTSTR) error_message );
  43.    }
  44. }
  45.  
  46.